/**
 * 
 */
package org.yelongframework.model.support.spring.beans.propertyeditors;

import java.text.DateFormat;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.propertyeditors.CustomDateEditor;
import org.yelongframework.model.property.nulls.ModelNullProperty;

/**
 * 自定义模型时间装订器
 * 
 * @since 1.0.0
 */
public class ModelCustomDateEditor extends CustomDateEditor {

	public ModelCustomDateEditor(DateFormat dateFormat, boolean allowEmpty, int exactDateLength) {
		super(dateFormat, allowEmpty, exactDateLength);
	}

	public ModelCustomDateEditor(DateFormat dateFormat, boolean allowEmpty) {
		super(dateFormat, allowEmpty);
	}

	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		if (StringUtils.isBlank(text)) {
			super.setValue(ModelNullProperty.DATE_NULL);
		} else {
			super.setAsText(text);
		}
	}

}
